<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
	<title>可用积分转账</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<script src="js/rem.js"></script>
	<script src="js/jquery.min.js" type="text/javascript"></script>
	<link rel="stylesheet" type="text/css" href="css/base.css"/>
	<link rel="stylesheet" type="text/css" href="css/page.css"/>
	<link rel="stylesheet" type="text/css" href="css/all.css"/>
	<link rel="stylesheet" type="text/css" href="css/mui.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/loaders.min.css"/>
	<link rel="stylesheet" type="text/css" href="css/loading.css"/>
	<link rel="stylesheet" type="text/css" href="slick/slick.css"/>
	<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css"/>
	<script src="js/vue-2.4.0.js"></script>
	<script src="js/axios_v0.12.0.js"></script>
	<link href="css/mui.picker.css" rel="stylesheet"/>
	<script type="text/javascript">
		var account = 0;
		$(window).load(function () {
			$(".loading").addClass("loader-chanage")
			$(".loading").fadeOut(300)

			//获取当前用户金额
			$.get("/cash/getCashByUid", function (result) {
				if (result.state == 1000) {
					if (result.msg == false) {
						$("#cash").html(0);
						account = 0;
					} else {
						$("#cash").html(result.data.account);
						account = result.data.account;
					}
				}
			})

		})

		function outMoney() {
			var username = $("#inUserName").val();
			var outMoney = $("#outMoney").val();
			//检查当前用户是否存在
			var param = {
				username: username
			}
			if (outMoney > account) {
				alert("用户余额不足，请先充值");
			} else {
				$.post("/users/checkUsername", param, function (result) {
					if (result.msg =="false") {
						alert("用户名不存在，请重新检查输入");
						window.location.href = "zhuanzhang.html";
					}else{
						var params = {
							inUsername: username,
							outMoney: outMoney
						}
						$.post("/cash/cashTransfer", params, function (result) {
							if (result.state == 1000) {
								alert("转账成功");
								window.location.href = "center.html";
							}
						})
					}
				})

			}


		}


	</script>
</head>
<!--loading页开始-->
<div class="loading">
	<div class="loader">
		<div class="loader-inner pacman">
			<div></div>
			<div></div>
			<div></div>
			<div></div>
			<div></div>
		</div>
	</div>
</div>
<!--loading页结束-->
<body>
<!--header star-->
<header class="mui-bar mui-bar1 mui-bar-nav mui-bar-nav1" id="header">
	<a class="btn" href="javascript:history.go(-1)">
		<i class="iconfont icon-fanhui"></i>
	</a>
	<div class="top-sch-box top-sch-boxtwo top-sch-boxthree flex-col">
		返回
	</div>
</header>
<!--header end-->
<div class="warp warpthree clearfloat">
	<div class="h-top h-topone clearfloat box-s">
		<p id="cash"></p>
		<span>我的钱包（元）</span>
	</div>
	<div class="recharge clearfloat">
		<div class="czhi clearfloat box-s">
			<p>转账金额</p>
			<input type="text" id="outMoney" value="" placeholder="请输入金额"/>
			<span>元</span>
		</div>
		<div class="czhi clearfloat box-s">
			<p>转入账户</p>
			<input type="text" id="inUserName" value="" placeholder=""/>
		</div>
		<div class="guize clearfloat box-s ra3">
			<h3>现金转账规则</h3>
			<div class="content clearfloat">
				请核实转账账户名和转账金额！！！
			</div>
		</div>
		<div class="bottom clearfloat">
			<a href="#" onclick="outMoney()" class="db fl btn ra3">确定</a>
			<a href="center.html" class="db fr btn ra3">取消</a>
		</div>
	</div>
</div>
</body>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/mui.picker.min.js"></script>
<script src="js/others.js"></script>
<script type="text/javascript" src="js/hmt.js"></script>
<script src="slick/slick.js" type="text/javascript"></script>
<!--插件-->
<link rel="stylesheet" href="css/swiper.min.css">
<script src="js/swiper.jquery.min.js"></script>
</html>
